package com.gitee.wsl.transform.validator.string.ext

import com.gitee.wsl.ext.any.isNotNull
import com.gitee.wsl.transform.validator.string.StringValidator
import com.gitee.wsl.transform.validator.string.then

fun StringValidator.notNull() = then("not null able") { it.isNotNull() }

fun StringValidator.nonEmptyRule() = then("non empty %s") {
    it.isNotEmpty()
}

fun StringValidator.contains(other:String) = then("%s is not contain $other"){
    it.contains(other)
}

fun StringValidator.endsWith(other:String) = then("ends with check false $other"){
    it.endsWith(other)
}

//fun StringValidator.strip(chars: CharArray) =
//    then { chars.fold(it) { acc, c -> acc.replace(c.toString(), "") } }
